<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.hs.core.db.*"%>
<%@page import="com.hs.core.cache.GlobalParamCache"%>
<%@page import="org.springframework.jdbc.core.JdbcTemplate"%>

<%
Cookie[] cookies=request.getCookies(); //读出用户硬盘上的Cookie，并将所有的Cookie放到一个cookie对象数组里面
Cookie sCookie=null; 
String svalue=null; 
String sname=null; 
String cookieName = null;
String cookiePassword = null;
if(null != cookies){
	for(int i=0;i<cookies.length;i++){    //用一个循环语句遍历刚才建立的Cookie对象数组
	sCookie=cookies[i];   //取出数组中的一个Cookie对象 
	sname=sCookie.getName(); //取得这个Cookie的名字
	svalue=sCookie.getValue(); //取得这个Cookie的内容
	if("dnmsabname2".equals(sname)){
		cookieName =  svalue;
	} 
	if("dnmsabpwd2".equals(sname)){
		cookiePassword =  svalue;
	} 
	}
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<%@ include file="include1.jsp"%> 
<script language="javascript" type="text/javascript" src="<%=path %>/thirtpart/highcharts216/highcharts.js"></script>
<script language="javascript" type="text/javascript" src="<%=path %>/thirtpart/highcharts216/modules/exporting.js"></script>
<% 
  String info = (String)request.getAttribute("alert");
  if(null == info)
     info = "";
  String userName = (String)request.getAttribute("username");
  if(null == userName){
     if(null != cookieName){
     	userName = cookieName;
     }else{
     	userName = "";
     }
  }
  session.invalidate();
  
  JdbcTemplateUtil util = JdbcTemplateUtil.getInst();
  GlobalParamCache cache = GlobalParamCache.getInst();
  String dburl1 = cache.getParamByKey("dnms_dburl_1");
  String dburl2 = cache.getParamByKey("dnms_dburl_2");
  String dbuser1 = cache.getParamByKey("dnms_dbusername_1");
  String dbuser2 = cache.getParamByKey("dnms_dbusername_2");
  String dbpwd1 = cache.getParamByKey("dnms_dbpassword_1");
  String dbpwd2 = cache.getParamByKey("dnms_dbpassword_2");
  JdbcTemplate jd1 = util.getJdbcTemplate(dburl1,dbuser1,dbpwd1);
  JdbcTemplate jd2 = util.getJdbcTemplate(dburl2,dbuser2,dbpwd2);
  StringBuffer yearbuffer = new StringBuffer("["); 
  StringBuffer countbuffer = new StringBuffer("["); 
   StringBuffer yearbuffer1 = new StringBuffer("["); 
  StringBuffer countbuffer1 = new StringBuffer("["); 
  
  StringBuffer onesql = new StringBuffer("select * from (select a.yearstr,count(*) as yearcount from (select substr(year,0,4) as yearstr from DNMS_MAGAZINE where year is not null) a group by a.yearstr) b order by yearstr desc");
  StringBuffer twosql = new StringBuffer("select * from (select DYNASTY,(select ORDNUM from hs_code where dicttype=23 and dictname=DYNASTY) as ordernum,count(*) as countstr from dnms_book where DYNASTY is not null group by DYNASTY) order by ordernum desc");
  Map yearmap = new HashMap();
  Integer curryear = new Integer(TimeUtil.getCurrentYear());
  for(int j =0;j<15;j++){
     int temp = (curryear - j) ;
      yearmap.put(temp+"",temp+"");
  }
 
  
  List magalist = jd2.queryForList(onesql.toString());
  if(magalist != null && magalist.size()>0){ 
            int count = magalist.size()-1;
      		for(int i = 0;i<magalist.size();i++){
       			Map datasta = (Map)magalist.get(count); 
      			String yearStr = (String)datasta.get("yearstr");
       			if(null == yearmap.get(yearStr)){
      			    count --;
      				continue;
      			}
      			String yearcount = datasta.get("yearcount") + "";
      			yearbuffer.append("'"+yearStr).append("'");
      			countbuffer.append(yearcount);
      			if(count != 0){
      				yearbuffer.append(",");
      				countbuffer.append(",");
      			}
      			count--;
      		}
    }	
    
    List booklist = jd1.queryForList(twosql.toString());
    if(booklist != null && booklist.size()>0){ 
            int count = booklist.size()-1;
      		for(int i = 0;i<booklist.size();i++){
       			Map datasta = (Map)booklist.get(count); 
      			String yearStr1 = (String)datasta.get("DYNASTY"); 
      			String yearcount1 = datasta.get("countstr") + "";
      			yearbuffer1.append("'"+yearStr1).append("'");
      			countbuffer1.append(yearcount1);
      			if(count != 0){
      				yearbuffer1.append(",");
      				countbuffer1.append(",");
      			}
      			count--;
      		}
    }	
    
    
   
%> 

<script language=JavaScript>
 <!--
if(self != top) top.location.href = window.location.href;
//-->
function checkform()
{
if(isNull(document.LoginForm.UserName.value)){
  alert("请输入用户名～！");
  document.all.UserName.focus();
  return false;
}
if(isNull(document.LoginForm.Password.value)){
  alert("请输入密码～！");
  document.all.Password.focus();
  return false;
}
return true;
}
function isNull(pvalue)
 {
   var RegularExp=/^\s*$/;
   if(RegularExp.test(pvalue))
   {
     return true;
   }
   return false;
 }
function submitPage(){
    var LoginForm = document.forms[0];
    if(checkform()){
       LoginForm.submit();
    }
	
}
function isEntry(e){
     if(document.all)e = event;
     if(e.keyCode==13) {
             submitPage();
     };
}
</script>
</head>

<body>
<div class="head">
    <img src="<%=imagePath %>logo.gif" class="logo"/>
    <div class="banner"></div>
    <div class="head_right">
    </div>
</div>
<div class="content">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" height="225">
          <tr>
          	<td class="l_bor"></td>
            <td valign="top" class="system_intro">
                <dl>
                    <dt><img src="<%=imagePath %>icon_1.gif"/>系统简介</dt>
                    <dd>
                        现代医学期刊文献在医药事业发展过程中占有举足轻重的作用，
                        它凝聚和传载了医家的医疗经验和教训，是我们发展医药事业的坚实基础和丰富宝库。以专科专病的形式，收集、整理和挖掘“多囊卵巢综合征”相关文献期刊，建立及时更新的文献研究数据库，形成重点病种“多囊卵巢综合征”期刊文献研究平台，整体提高重点病种文献研究水平和效率，
                        及时评估分析国内外相关领域研究进展和状况，明确临床需求和问题，为重点病种研究提供服务和支撑。 
                  </dd>
               </dl>
               <dl>
                    <dt><img src="<%=imagePath %>icon_2.gif"/>系统目标</dt> 
                    <dd>收集、整理国内外期刊发表的中西医等治疗“多囊卵巢综合征”的相关文献信息，建立文献信息加工平台，深入加工挖掘文献信息，形成及时更新的文献研究数据库，研发检索分析平台，为评估分析国内外相关领域研究进展和状况及临床应用研究提供数据支撑服务，具体包含以下几个方面：
 	文献期刊题录信息管理
 	文献期刊信息加工
 	数据检索分析应用
</dd>
                </dl>
            </td>
           	<td class="r_bor"></td>
           	<form name="LoginForm" action="<%=basePath %>logon2.do"  method="post"> 
            <td class="login_parent">
                用户名<input name="UserName" type="text" value="<%=userName==null?"":userName %>" class="name"/><br />
                密　码<input name="Password" type="password" class="pass" value="<%=cookiePassword==null?"":cookiePassword %>"/> <br />
                <span><input name="rememberme" type="checkbox" value="1" <%if(null != cookieName){out.println(" checked");} %>/> 记住用户名密码<font color=red><strong><%=info%></strong></font></span> 
                <p><input  onclick="submitPage();" type="button" class="login"/><input name="" type="button" class="cance"/></p>
            </td>
            </form>
        </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="chart">
          <tr>
            <td class="p_10">
               <table width="100%" border="0" cellspacing="10" cellpadding="0" class="chart_bg">
                  <tr>
                    <td width="50%">
                        <dl>
                            <dt>现代文献数据趋势统计</dt>
                            <dd><div id="container" class="highcharts-container" style="height:100%; margin: 0 2em; clear:both; min-width: 300px"></div></dd>
                        </dl>
                    </td>
                    <td width="50%">
                        <dl>
                            <dt>古籍文献数据趋势统计</dt>
                            <dd><div id="container1" class="highcharts-container" style="height:100%; margin: 0 2em; clear:both; min-width: 300px"></div></dd>
                        </dl>
                    </td>
                  </tr>
             </table>
            </td>
     </table>
</div>
<div class="footer"><spring:message code="sys.copyright" /></div>
</body>
</html> 
<script language="javascript" type="text/javascript">
 <%
 yearbuffer.append("]");
 countbuffer.append("]");
 
 yearbuffer1.append("]");
 countbuffer1.append("]");
 
 %>

var chart;
var chart1;
$(document).ready(function() {
   chart = new Highcharts.Chart({
      chart: {
         renderTo: 'container',
         defaultSeriesType: 'line'
      },
      title: {
         text: '<strong><font color=red size=3>中医治疗多囊卵巢综合征相关文献数量历年趋势统计图</font></strong>'
      },
      subtitle: {
         text: ''
      },
      xAxis: {
         categories: <%=yearbuffer%>
      },
      yAxis: {
         title: {
            text: '<strong>文献数量（篇）</strong>'
         }
      },
      tooltip: {
         enabled: false,
         formatter: function() {
            return '';
         }
      },
      plotOptions: {
         line: {
            dataLabels: {
               enabled: false
            },
            enableMouseTracking: false
         }
      },
		exporting: {
		
		filename: "chart",
		
		type: "image/png",
		
		url: '<%=basePath%>image/export.do',
		
		width: 800
		
		},
   series: [{
         name: '文献发表数量',
         data: <%=countbuffer%>
      }]
   });
   
   chart1 = new Highcharts.Chart({
      chart: {
         renderTo: 'container1',
         defaultSeriesType: 'line'
      },
      title: {
         text: '<strong><font color=red size=3>中医治疗多囊卵巢综合征古代文献数量趋势统计图</font></strong>'
      },
      subtitle: {
         text: ''
      },
      xAxis: {
         categories: <%=yearbuffer1%>
      },
      yAxis: {
         title: {
            text: '<strong>文献数量（篇）</strong>'
         }
      },
      tooltip: {
         enabled: false,
         formatter: function() {
            return '';
         }
      },
      plotOptions: {
         line: {
            dataLabels: {
               enabled: false
            },
            enableMouseTracking: false
         }
      },
		exporting: {
		
		filename: "chart",
		
		type: "image/png",
		
		url: '<%=basePath%>image/export.do',
		
		width: 800
		
		},
   series: [{
         name: '古文献数量',
         data: <%=countbuffer1%>
      }]
   });
   
   
});



 
</script>